package com.mes.spc.rule;

import java.util.ArrayList;
import java.util.List;

public class SpcRule6 extends SPCCommandbase {

    public int id =6;
    public int warningCount =5;
    public String title = "规则6";
    public String description="连续5点中有4点落在中心线同一侧的1倍sigma区以外";
    private List<Double> old = new ArrayList<Double>();
    private int count;
    public boolean excute(double data, double usl, double lsl, double ucl, double lcl, double standard)
    {
        double bu = standard + ucl / 3;
        double bl = standard + lcl / 3;
        int u = 0;
        int l = 0;
        old.add(data);
        count++;
        if (count > 5)
        {
            count--;
            old.remove(0);
        }
        for(double o : old)
        {
            if (o > bu)
                u++;
            else if (o < bl)
                l++;
        }
        if (u >= 4 || l >= 4)
            return true;
        return false;
    }

    public int getId() {
        return id;
    }

    public int getWarningCount() {
        return warningCount;
    }

    public String getTitle() {
        return title;
    }

    public String getDescription() {
        return description;
    }
}
